package com.ruoyi.web.controller.gym;

import com.ny.domain.MarketingActivityDO;
import com.ny.domain.MemberDO;
import com.ny.domain.ProductPurchaseDO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.MarketingActivityDTO;
import com.ny.dto.PageResult;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.MarketingActivityQuery;
import com.ny.query.MemberQuery;
import com.ny.query.QueryGroup;
import com.ny.service.MarketingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.lang.Integer;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 营销工具模块
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("营销工具模块")
@RequestMapping("marketing")
@RestController
public class MarketingController {

    @Autowired
    private MarketingService marketingService;

    /**
     * 发布营销活动
     *
     * @param marketingActivityDTO 营销活动信息
     * @return
     */
    @RequestMapping(value = "/activity/publish", method = RequestMethod.POST)
    @ApiOperation("发布营销活动")
    @ResponseBody
    public RestResult<Boolean> publishMarketingActivity(@RequestBody @Validated(CreateGroup.class) MarketingActivityDTO marketingActivityDTO) {
        Boolean result = marketingService.publishMarketingActivity(marketingActivityDTO);
        return RestResult.success(result);
    }

    /**
     * 更新营销活动
     *
     * @param marketingActivityDTO 营销活动信息
     * @return
     */
    @RequestMapping(value = "/activity/update", method = RequestMethod.PUT)
    @ApiOperation("更新营销活动")
    @ResponseBody
    public RestResult<Boolean> updateMarketingActivity(@RequestBody @Validated(UpdateGroup.class) MarketingActivityDTO marketingActivityDTO) {
        Boolean result = marketingService.updateMarketingActivity(marketingActivityDTO);
        return RestResult.success(result);
    }

    /**
     * 删除营销活动
     *
     * @param marketingActivityDTO 营销活动信息
     * @return
     */
    @RequestMapping(value = "/activity/delete", method = RequestMethod.DELETE)
    @ApiOperation("删除营销活动")
    @ResponseBody
    public RestResult<Boolean> deleteMarketingActivity(@RequestBody @Validated(DeleteGroup.class) MarketingActivityDTO marketingActivityDTO) {
        Boolean result = marketingService.deleteMarketingActivity(marketingActivityDTO);
        return RestResult.success(result);
    }

    /**
     * 查询营销活动列表
     *
     * @param marketingActivityQuery 营销活动查询条件
     * @return
     */
    @RequestMapping(value = "/activity/list", method = RequestMethod.GET)
    @ApiOperation("查询营销活动列表")
    public RestResult<PageResult<MarketingActivityDO>> listMarketingActivities(@Validated(QueryGroup.class) MarketingActivityQuery marketingActivityQuery) {
        PageResult<MarketingActivityDO> result = marketingService.listMarketingActivities(marketingActivityQuery);
        return RestResult.success(result);
    }

    /**
     * 获取会员消费分析
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/consumption/analysis", method = RequestMethod.GET)
    @ApiOperation("获取会员消费分析")
    public RestResult<ProductPurchaseDO> getMemberConsumptionAnalysis(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        ProductPurchaseDO result = marketingService.getMemberConsumptionAnalysis(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 获取所有会员消费分析
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/consumption/analysis/all", method = RequestMethod.GET)
    @ApiOperation("获取所有会员消费分析")
    public RestResult<List<ProductPurchaseDO>> getAllMemberConsumptionAnalysis(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        List<ProductPurchaseDO> result = marketingService.getAllMemberConsumptionAnalysis(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 查询会员基本信息
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/info", method = RequestMethod.GET)
    @ApiOperation("查询会员基本信息")
    public RestResult<MemberDO> getMemberInfo(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        MemberDO result = marketingService.getMemberInfo(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 查询会员消费记录
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/consumption/record", method = RequestMethod.GET)
    @ApiOperation("查询会员消费记录")
    public RestResult<List<ProductPurchaseDO>> getMemberConsumptionRecord(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        List<ProductPurchaseDO> result = marketingService.getMemberConsumptionRecord(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 查询会员购买记录
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/purchase/record", method = RequestMethod.GET)
    @ApiOperation("查询会员购买记录")
    public RestResult<List<ProductPurchaseDO>> getMemberPurchaseRecord(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        List<ProductPurchaseDO> result = marketingService.getMemberPurchaseRecord(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 查询会员等级信息
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/member/level/info", method = RequestMethod.GET)
    @ApiOperation("查询会员等级信息")
    public RestResult<Integer> getMemberLevelInfo(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        Integer result = marketingService.getMemberLevelInfo(memberQuery);
        return RestResult.success(result);
    }
}
